home *** CD-ROM | disk | FTP | other *** search
- /* ARexx script for WRITE and SC_SCMSG communication */
-
- /*
- * written 20/09/1993 by Lars Hanke
- * © 1993 by MGR-Software, Asgrad
- * contact: mgr@asgard.bo.open.de
- *
- * Installation:
- * - set the 'helppath' variable following this comment to where your
- * SAS/C AmigaGuide files can be found. By default they are installed
- * to SC:Help/
- *
- * - set the SCMSG tool's defaults by calling "SCMSG", Project menu,
- * "Set options" to:
- * Hidden
- * NoRexxOnly - isn't supported by SCMSG otherwise
- * NoAutoEdit
- *
- * PortName: ""
- * EditCommand: "rx sc.wrx init"
- * GotoFile: ""
- * GoToLine: ""
- *
- * click "Use" and select "Save options" in the Project menu.
- *
- * - add the following lines to your WRITE configuration file
- *
- * /* SC support controls */
- *
- * KEY "numpad control 2" DoRexx "sc.wrx next" 1;
- * KEY "numpad control 8" DoRexx "sc.wrx last" 1;
- * KEY "numpad control 7" DoRexx "sc.wrx begin" 1;
- * KEY "numpad control 1" DoRexx "sc.wrx end" 1;
- * KEY "numpad control enter" DoRexx "sc.wrx correct" 1;
- * KEY "numpad alt 7" DoRexx "sc.wrx build" 1;
- * KEY "numpad alt 1" DoRexx "sc.wrx done" 1;
- * KEY "numpad control 5" DoRexx "sc.wrx index" 1;
- *
- *
- * - compile your programs using the 'errrexx' compiler option for SC
- *
- * Operation:
- * As you probably have noted all operation hotkeys are situated on
- * the numeric keypad and qualified by control. As this is the way
- * of LSE's navigation functions you should be able to keep it in
- * mind easily:
- *
- * Up: (8) - goto previous message
- * Down: (2) - goto next message
- * Home: (7) - goto first message
- * End: (1) - goto last message
- * Enter: - remove current message and goto next one
- * Center: (5) - display Guide page for message
- *
- * The above commands move to the beginning of the line that caused the
- * error. New files are loaded automatically, if necessary. A security
- * request is done, if the current file was changed. The errormessage
- * is displayed in a standard text requester. Main control is qualified
- * with alt:
- *
- * Home: - rebuild the current project
- * End: - quit the SCMSG program
- *
- * From the above configuration example operation and the meaning of
- * the argument 'action' should be clear.
- *
- * When the SCMSG window pops up, doubleclick any message you want to
- * start (or later go on) with
- *
- */
-
- helppath = "XDOC:guides/help/"
-
- ARG action
-
- IF ~show('P',"SC_SCMSG") THEN
- DO
- if (action = "INIT") then say "You should not invoke me manually!"
- else do
- if show('P',"WRITE") then
- do
- address 'WRITE'
- 'MessageOK (No SCMSG ARexx-server running)'
- exit 0
- end
- else say "You should not invoke me manually!"
- end
- END
-
- IF ~show('P',"WRITE")
- THEN DO
- if action = "INIT" then
- do
- ADDRESS "COMMAND"
- "run >NIL: <NIL: dh0:Text/WRITE"
- "WB:REXXC/WaitForPort <NIL: >NIL: WRITE"
- end
- else do
- say 'call me with the "Init" option first'
- exit 5
- end
- END
-
- IF action = "QUIT" then
- do
- address "SC_SCMSG"
- 'quit'
- exit 0
- end
-
- options results
-
- Port = getclip('SC_WRITE_PORT')
- ID = getclip('SC_WRITE_ID')
-
- if action = "INIT" then
- do
- address 'WRITE'
- if ((Port == "") | ~show('P',Port)) then
- do
- 'NEWED ""'
- ID = RESULT
- if ~setclip('SC_WRITE_ID',ID) then
- do
- "MessageOK (Kann kein ID Clipboard bekommen!)"
- exit 20
- end
- OPENPORT ID
- Port = RESULT
- IF Port="" THEN DO
- "MessageOK (Es konnte kein Port für SAS/C geöffnet werden)"
- exit 20
- end
- if ~setclip('SC_WRITE_PORT',Port) then
- do
- "MessageOK (Kann kein Port Clipboard bekommen!\nBitte schliessen Sie das Fenster)"
- WaitPort ID
- exit 20
- end
- call setclip('SC_WRITE_WINDOW',0)
- end
- end
- else do
- if Port = "" then
- do
- address 'WRITE'
- 'MessageOK (Call me with the "Init" option first)'
- exit 0
- end
- else if ~show('P',Port) then
- do
- address 'WRITE'
- 'MessageOK (The current window is not the master)'
- exit 0
- end
- end
-
- if action ~= "INIT" then
- do
- address 'SC_SCMSG'
- select
- when action = "NEXT" then 'next'
- when action = "LAST" then 'prev'
- when action = "BEGIN" then 'top'
- when action = "END" then 'bottom'
- when action = "CORRECT" then 'delete'
- when action = "SELECT" then
- do
- 'show activate'
- exit 0
- end
- when action = "DONE" then 'quit'
- when action = "BUILD" then 'build'
- when action = "INDEX" then
- do
- 'errnum'
- num = RESULT
- if num ~= "" then
- do
- num = right(num,3,'0')
-
- address 'COMMAND'
- 'run >nil: amigaguide' helppath||'scmsg.guide doc scm'||num
- exit 0
- end
- end
- otherwise action = "UNDEF"
- end
- end
-
- INTERPRET ADDRESS Port
-
- select
- when action = "DONE" then msg="SCMSG terminated"
- when action = "BUILD" then msg="Rebuilding ..."
- when action = "UNDEF" then msg="REXX-Error: undefined action code"
- otherwise msg=""
- end
-
- if msg ~= "" then
- do
- 'MessageOK "'||msg||'"'
- exit 0
- end
-
- 'GETVAR (_WinMode)'
- if( RESULT ~= 0 ) then
- do
- if getclip('SC_WRITE_WINDOW') == 1 then 'WINDOW 0 0 0 0'
- else do
- WINDOWSIZE = "0 0 0 0"
- IF Open(File,"ENV:"||WRITESIZE,r) THEN
- DO
- WINDOWSIZE = ReadLn(File);
- call Close(File)
- END
- 'Window' WINDOWSIZE
- call setclip('SC_WRITE_WINDOW',1);
- end
- end
-
- 'GETVAR (_FILENAME)'
- cfile = RESULT
-
- address 'SC_SCMSG'
- 'FILE'
- nfile = RESULT
-
- 'errnum'
- if RESULT = "" then
- do
- 'quit'
- INTERPRET ADDRESS Port
- 'MessageOK (All errors corrected!)'
- call setclip('SC_WRITE_PORT',"")
- call setclip('SC_WRITE_ID',"")
- exit(0)
- end
-
- if (cfile ~= nfile) then
- do
- INTERPRET ADDRESS Port
-
- 'GETVAR (_Changed)'
- if( RESULT = 1 ) then
- do
- 'ASK "Your current file was changed!\nSave it?" "_Forget ^|_Save *"'
- 'GETVAR (_RN)'
- if (RESULT ~= 0) then 'Save "'||cfile||'" {}'
- end
- 'Open "'||nfile||'"'
- address 'SC_SCMSG'
- end
-
- 'line'
- line = RESULT
- 'text'
- msg = RESULT
- 'class'
- class = RESULT
-
- INTERPRET ADDRESS Port
- 'GOTO 1' line
- txt = debrace(class||':' msg)
- "MessageOK ("||txt||")"
-
- exit 0
-
- debrace: procedure /* remove braces from texts */
-
- parse arg line
-
- do until p = 0 /* replace parenthesa by braces, */
- p = pos('(',line) /* because we use the former as */
- if p ~= 0 then /* quotes for WRITE itself. */
- do
- line = delstr(line,p,1)
- line = insert('{',line,p-1)
- end
- end
-
- do until p = 0
- p = pos(')',line)
- if p ~= 0 then
- do
- line = delstr(line,p,1)
- line = insert('}',line,p-1)
- end
- end
-
- p = pos('"',line) /* replace " by ', for we also */
- do while p ~= 0 /* need outer quotes */
- line = delstr(line,p,1)
- line = insert("'",line,p-1)
- p = pos('"',line)
- end
-
- line = strip(line)
- if length(line) > 230 then
- line = left(line,230) /* we may only pass 255 chars a time */
-
- 'GetVar (_WinWidth)' /* insert \n to stay in window */
- width = RESULT
- width = width-trunc(0.2*width)
- l = length(line)
- p = 1
- do while l > width
- p = p+width
- s = left(line,p)
- r = words(s)
- i = wordindex(line,r)
- line = insert("\n",line,i)
- p = p+2
- l = length(line) - (i+2);
- end
-
- return line
-
-
-
-